#!/bin/ksh

##############################################################################
#
# AIX 3.2 Internationalization Sample Environment Package
#
# (C) COPYRIGHT International Business Machines Corp. 1989 All Rights Reserved
#
# US Government Users Restricted Rights - Use, duplication or disclosure 
# restricted by GSA ADP Schedule Contract with IBM Corp.
#
# INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PACKAGE OF SAMPLE
# ENVIRONMENT FILES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, AS IS, 
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
# PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 
# SAMPLE ENVIRONMENT FILES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, IS
# WITH YOU. SHOULD ANY PART OF THE SAMPLE ENVIRONMENT PACKAGE PROVE DEFECTIVE,
# YOU (AND NOT IBM) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICE, SUPPORT,
# REPAIR OR CORRECTION.
#
# Each copy of the AIX 3.2 ILS Sample Environment Package or derivative work
# thereof must reproduce the IBM Copyright notice and the complete contents of
# this notice.
#
##############################################################################

cat /usr/dt/config/C/sys.dtwmrc | awk -f $HOME/bin/dtwmrc_1.awk > /tmp/dtwmrc_1
cat /usr/dt/config/C/sys.dtwmrc | awk -f $HOME/bin/dtwmrc_2.awk > /tmp/dtwmrc_2

exec > /tmp/dtwmrc_3
echo "Menu IBMPC\n{"
for LINE in `grep PC$ $HOME/tables/ASCII`
do
	NAME=`echo $LINE | cut -d: -f4`
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "\t\"$NAME\"\t\tf.menu $SYS_LOC"
done
echo "}\n"

for LINE in `grep PC$ $HOME/tables/ASCII`
do
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "Menu $SYS_LOC\n{"
	echo "\t\"Terminal\"\t\tf.exec \"langterm $SYS_LOC\""
	echo "\t\"Sys. Management\"\t\tf.exec \"langsmit $SYS_LOC\""
	echo "\t\"Visual User Mgm't\"\t\tf.exec \"langsmit -c xuserm $SYS_LOC\""
	echo "\t\"Visual Print Mgm't\"\t\tf.exec \"langsmit -c xprintm $SYS_LOC\""
	echo "\t\"Pad Editor\"\t\tf.exec \"langdtpad $SYS_LOC\""
	echo "\t\"Sample Editor\"\t\tf.exec \"langxmedit $SYS_LOC\""
	echo "\t\"Show KB\"\t\tf.exec \"langxmkb $SYS_LOC\""
	echo "\t\"Set KB\"\t\tf.exec \"setkb $SYS_LOC\""
	echo "}\n"
done

echo "Menu ISO8859\n{"
for LINE in `grep ISO$ $HOME/tables/ASCII`
do
	NAME=`echo $LINE | cut -d: -f4`
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "\t\"$NAME\"\t\tf.menu $SYS_LOC"
done
echo "}\n"

for LINE in `grep ISO$ $HOME/tables/ASCII`
do
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "Menu $SYS_LOC\n{"
	echo "\t\"Terminal\"\t\tf.exec \"langterm $SYS_LOC\""
	echo "\t\"Msmit\"\t\tf.exec \"langsmit $SYS_LOC\""
	echo "\t\"Xmedit\"\t\tf.exec \"langxmedit $SYS_LOC\""
        echo "\t\"Sys. Management\"\t\tf.exec \"langsmit $SYS_LOC\""
        echo "\t\"Visual User Mgm't\"\t\tf.exec \"langsmit -c xuserm $SYS_LOC\
""
        echo "\t\"Visual Print Mgm't\"\t\tf.exec \"langsmit -c xprintm $SYS_LO
C\""
        echo "\t\"Pad Editor\"\t\tf.exec \"langdtpad $SYS_LOC\""
        echo "\t\"Sample Editor\"\t\tf.exec \"langxmedit $SYS_LOC\""

	echo "\t\"Show KB\"\t\tf.exec \"langxmkb $SYS_LOC\""
	echo "\t\"Set KB\"\t\tf.exec \"setkb $SYS_LOC\""
	echo "}\n"
done

echo "Menu EUC\n{"
for LINE in `grep EUC$ $HOME/tables/ASCII`
do
	NAME=`echo $LINE | cut -d: -f4`
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "\t\"$NAME\"\t\tf.menu $SYS_LOC"
done
echo "}\n"

for LINE in `grep EUC$ $HOME/tables/ASCII`
do
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "Menu $SYS_LOC\n{"
	echo "\t\"Terminal\"\t\tf.exec \"langterm $SYS_LOC\""
	echo "\t\"Msmit\"\t\tf.exec \"langsmit $SYS_LOC\""
	echo "\t\"Xmedit\"\t\tf.exec \"langxmedit $SYS_LOC\""
        echo "\t\"Sys. Management\"\t\tf.exec \"langsmit $SYS_LOC\""
        echo "\t\"Visual User Mgm't\"\t\tf.exec \"langsmit -c xuserm $SYS_LOC\
""
        echo "\t\"Visual Print Mgm't\"\t\tf.exec \"langsmit -c xprintm $SYS_LO
C\""
        echo "\t\"Pad Editor\"\t\tf.exec \"langdtpad $SYS_LOC\""
        echo "\t\"Sample Editor\"\t\tf.exec \"langxmedit $SYS_LOC\""

	echo "\t\"Show KB\"\t\tf.exec \"langxmkb $SYS_LOC\""
	echo "\t\"Set KB\"\t\tf.exec \"setkb $SYS_LOC\""
	echo "}\n"
done

echo "Menu Others\n{"
for LINE in `grep -v PC$ $HOME/tables/ASCII | grep -v ISO$ | grep -v EUC$`
do
	NAME=`echo $LINE | cut -d: -f4`
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "\t\"$NAME\"\t\tf.menu $SYS_LOC"
done
echo "}\n"

for LINE in `grep -v PC$ $HOME/tables/ASCII | grep -v ISO$ | grep -v EUC$`
do
	SYS_LOC=`echo $LINE | cut -d: -f1`
	echo "Menu $SYS_LOC\n{"
	echo "\t\"Terminal\"\t\tf.exec \"langterm $SYS_LOC\""
        echo "\t\"Sys. Management\"\t\tf.exec \"langsmit $SYS_LOC\""
        echo "\t\"Visual User Mgm't\"\t\tf.exec \"langsmit -c xuserm $SYS_LOC\
""
        echo "\t\"Visual Print Mgm't\"\t\tf.exec \"langsmit -c xprintm $SYS_LO
C\""
        echo "\t\"Pad Editor\"\t\tf.exec \"langdtpad $SYS_LOC\""
        echo "\t\"Sample Editor\"\t\tf.exec \"langxmedit $SYS_LOC\""
	echo "\t\"Show KB\"\t\tf.exec \"langxmkb $SYS_LOC\""
	echo "\t\"Set KB\"\t\tf.exec \"setkb $SYS_LOC\""
	echo "}\n"
done

if [ -r $HOME/.dt/dtwmrc ]
then
	mv $HOME/.dt/dtwmrc $HOME/.dt/dtwmrc.orig
fi
cat /tmp/dtwmrc_1 /tmp/dtwmrc_2 /tmp/dtwmrc_3 > $HOME/.dt/dtwmrc

rm -f /tmp/dtwmrc_1
rm -f /tmp/dtwmrc_2
rm -f /tmp/dtwmrc_3
